import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { SkillItem } from "../SkillItem";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { SkillInfo } from "../../../model/SkillInfo";
import { ToolTipsManager } from "../../../../../com/mui/manager/ToolTipsManager";
import { ToolTipInfo } from "../../../model/ToolTipInfo";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
type int = number;
//class SkillItemGuild
    
    export  class SkillItemGuild extends GCellRenderer
    {
        constructor()
        {
            super();
            this.initUI();
            return;
        }

        protected initUI(): void
        {
            this._bg = ObjCreate.createBg(0, 0, this.width, this.height, this, ImagesConst.DisabledBg);
            this._itemBg = GlobalClass.getBitmap(ImagesConst.PackItemBg);
            this._itemBg.x = 10;
            this._itemBg.y = 11;
            this._skillItem = new SkillItem();
            this._skillItem.x = this._itemBg.x + 3;
            this._skillItem.y = this._itemBg.y + 3;
            this._skillName = ObjCreate.createTextField("", this._skillItem.x + this._skillItem.width + 10, this._skillItem.y, 70, 20, this);
            this._skillEffect = ObjCreate.createTextField("", this._skillName.x, this._skillName.y + 20, 70, 20, this);
            this._skillName.mouseEnabled = false;
            this._skillEffect.mouseEnabled = false;
            addChild(this._itemBg);
            addChild(this._skillItem);
            return;
        }

        public updateLearnedAble(): void
        {
            if (this.skillInfo) 
            {
                if (this.skillInfo.learned) 
                {
                    this._skillItem.filters = null;
                    if (this._clickEd) 
                    {
                        this._itemBg.filters = [FilterConst.skillItemFilter];
                    }
                    else 
                    {
                        this._itemBg.filters = null;
                    }
                }
                else if (this.skillInfo.learnedAble) 
                {
                    this._skillItem.filters = null;
                    if (this._clickEd) 
                    {
                        this._itemBg.filters = [FilterConst.skillItemFilter];
                    }
                    else 
                    {
                        this._itemBg.filters = null;
                    }
                }
                else 
                {
                    this._skillItem.filters = [FilterConst.colorFilter2];
                    if (this._clickEd) 
                    {
                        this._itemBg.filters = [FilterConst.colorFilter2, FilterConst.skillItemFilter];
                    }
                    else 
                    {
                        this._itemBg.filters = [FilterConst.colorFilter2];
                    }
                }
            }
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (this._clickEd == arg1) 
            {
                return;
            }
            this._clickEd = arg1;
            if (this._clickEd) 
            {
                if (this.skillInfo.learned) 
                {
                    this._itemBg.filters = [FilterConst.skillItemFilter];
                }
                else if (this.skillInfo.learnedAble) 
                {
                    this._itemBg.filters = [FilterConst.skillItemFilter];
                }
                else 
                {
                    this._itemBg.filters = [FilterConst.colorFilter2, FilterConst.skillItemFilter];
                }
            }
            else if (this.skillInfo.learned) 
            {
                this._itemBg.filters = null;
            }
            else if (this.skillInfo.learnedAble) 
            {
                this._itemBg.filters = null;
            }
            else 
            {
                this._itemBg.filters = [FilterConst.colorFilter2];
            }
            return;
        }

        public get skillInfo(): SkillInfo
        {
            return this._skillItem.skillInfo;
        }

        public set amount(arg1: int)
        {
            this._skillItem.amount = arg1;
            return;
        }

        public set levelUpAble(arg1: Boolean)
        {
            return;
        }

        public set levelUpAbleEffect(arg1: Boolean)
        {
            return;
        }

        public set toolTipDataFunction(arg1: Function)
        {
            if (arg1 != null) 
            {
                ToolTipsManager.register(this);
            }
            else 
            {
                ToolTipsManager.unregister(this);
            }
            this._toolTipDataFunction = arg1;
            return;
        }

        public get toolTipDataFunction(): Function
        {
            return this._toolTipDataFunction;
        }

        protected getToolTipData(): ToolTipInfo
        {
            return this.skillInfo.getToolTipInfo();
        }

        public get skillItem(): SkillItem
        {
            return this._skillItem;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._skillItem.data = arg1;
            this.amount = this.skillInfo.tSkill.skillLevel;
            this.updateLearnedAble();
            this.toolTipDataFunction = this.getToolTipData;
            this.levelUpAble = this.skillInfo.levelUpAbleShow;
            this.levelUpAbleEffect = this.skillInfo.levelUpAbleEffect;
            this._skillName.text = this.skillInfo.skillName;
            this._skillEffect.text = this.skillInfo.getUseType();
            return;
        }

        public /* override */ get toolTipData()
        {
            if (this.toolTipDataFunction != null) 
            {
                return this.toolTipDataFunction();
            }
            return super.toolTipData;
        }

        public /* override */ setSize(arg1: number, arg2: number): void
        {
            super.setSize(117, 60);
            return;
        }

        public /* override */ get width(): number
        {
            return 117;
        }

        public /* override */ get height(): number
        {
            return 60;
        }

        /* internal */ /* var */_bg: ScaleBitmap;

        /* internal */ /* var */_itemBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_skillItem: SkillItem;

        /* internal */ /* var */_skillName: Object /* flash.text.TextField */;

        /* internal */ /* var */_skillEffect: Object /* flash.text.TextField */;

        /* internal */ /* var */_clickEd: Boolean;

        protected /* var */_toolTipDataFunction: Function;
    }
